%Paul Ozog

%Problem 1
f = linspace(30e6, 3000e6, 10000);
w = 2*pi*f;

L = 10e-9;
C = 10e-12;
R = 5;

Z1 = j*w*L ./ (1 - w.^2*L*C);
Z2 = (j*w*L + R) ./ (1 - w.^2*L*C + j*w*R*C);
Z3 = j*w*L - (j ./ (w*C));
Z4 = Z3 + R;

subplot(2,2,1);
plot(f / 1e6, abs(Z1));
xlabel('Frequency (MHz)');
ylabel('|\Omega|');

subplot(2,2,2);
plot(f / 1e6, abs(Z2));
xlabel('Frequency (MHz)');
ylabel('|\Omega|');

subplot(2,2,3);
plot(f / 1e6, abs(Z3));
xlabel('Frequency (MHz)');
ylabel('|\Omega|');

subplot(2,2,4);
plot(f / 1e6, abs(Z4));
xlabel('Frequency (MHz)');
ylabel('|\Omega|');

figure;

%Problem 2
L = 10e-9;
C = 1e-12;
R = 0:300;
w0 = sqrt(1/(L*C) - (R/L).^2);

plot(R, real(w0) / (2*pi));
title('Resonant frequency vs. Resistor');
xlabel('Resistance (\Omega)');
ylabel('Frequency (Hz)');

%Problem 4
a = .2019e-3;
l = 5e-3;
d = .5e-3;
r = 2.5e-3;
u0= 1.256e-6;
e0= 8.85e-12;
N = 10;
sigCu = 5.8e7;

L = (pi*r^2*u0*N*N) / l;
Cs= (e0*2*pi*r*N*a) / (l/N);
RDC=(2*pi*r*N) / (sigCu *pi*a^2);

delta=(pi*f*u0*sigCu).^-.5;
figure;
%semilogx(f, delta);
Z4 = 1 ./ ( (1 ./ (j*w*L + RDC)) + j*w*Cs);

RAC = a./(2*delta) * RDC;
Z5 = 1 ./ ( (1 ./ (j*w*L + (RAC + RDC))) + j*w*Cs);

loglog(f, abs(j*w*L), 'r');
hold on
loglog(f, abs(Z4), 'g');
loglog(f, abs(Z5), 'b*');
title('Impedance of Real Inductor');
xlabel('f, Hz');
ylabel('|Z|, \Omega');

%Problem 5
f = [100e6, 1e9, 10e9];
w = 2*pi*f;

sigAl = 4e7;
a = .819e-3;
l = 5e-2;
RDC = l / (pi*a^2*sigAl);

delta=(pi*f*u0*sigAl).^-.5;
RAC = a./(2*delta) * RDC;
L   = (a./(2*delta) * RDC) ./ w;
figure;
loglog(f, abs(j*w.*L + RDC + RAC), '.');
axis([100e5 10e10 0.01 2]);

%Problem 6
DiCond = ((2*pi*10e9)*10*e0) / .0004
